package junit.framework;

import java.util.ArrayList;

import cleanstarxchange.server.Stock;

public class StockTest extends TestCase {

	     private Stock stk;


	     /**
	      * Sets up the test fixture. 
	      * (Called before every test case method.) 
	      */ 
	     protected void setUp() { 
	 		 stk = new Stock( "Brian Kang", "BKA", new Long(9), 13.0, new ArrayList<Double>() );
	     } 


	     /**
	      * Tears down the test fixture. 
	      * (Called after every test case method.) 
	      */ 
	     protected void tearDown() { 
	          stk = null; 
	     } 


	     public void testInitialSetting() { 
	          assertEquals("Checking initial price", 13.0, stk.getInitialPrice());
	          assertEquals("Checking current price", 13.0, stk.getCurrentPrice());
	          assertEquals("Checking name", "Brian Kang", stk.getName());
	          assertEquals("Checking highest price", 13.0, stk.getHighPrice());
	          assertEquals("Checking lowest price", 13.0, stk.getLowPrice());
	          
	          //assertEquals("Previous price should be 0", 0.0 , );
	     } 
	     public void testUpdatePrice(){
	    	 stk.updatePrice(80.0);
	         assertEquals("Checking initial price", 13.0, stk.getInitialPrice());
	         assertEquals("Checking updated price", 80.0, stk.getCurrentPrice());
	         assertEquals("Checking highest price", 80.0, stk.getHighPrice());
	         assertEquals("Checking lowest price", 13.0, stk.getLowPrice());
	         
	         stk.updatePrice(7.13);
	         assertEquals("Checking updated price", 7.13, stk.getCurrentPrice());
	         assertEquals("Checking highest price", 80.0, stk.getHighPrice());
	         assertEquals("Checking lowest price", 7.13, stk.getLowPrice());

	    
	     }

	     public void testForException() { 
	          try { 
	        	  stk.getPreviousPrice(1);
	        	  fail("Should raise an IndexOutOfBoundsException");
	          } 
	          catch (IndexOutOfBoundsException success) {
	          } 
	     } 

	
}
